package com.huynhchihieu.web.service;

import java.util.ArrayList;
import java.util.List;

import javax.jws.WebMethod;
import javax.jws.WebService;
import  javax.jws.WebResult;

/**
 * 
 * @author hieu.huynh
 * 	The implementing class may explicitly reference an SEI through the endpointInterface element 
 * of the @WebService annotation, but is not required to do so. If no endpointInterface is specified in @WebService
 * , an SEI is implicitly defined for the implementing class.
 *
 */
@WebService(name="TestHelloWs", targetNamespace="http://www.huynhchihieu.tutorial", 
	portName="TestHelloWsPortName", serviceName="HelloWsServiceName")
public class HelloWs {
    private String message = new String("Hello, ");
    
    /**
     *  required default public constructor
     */
    public HelloWs() {}

    /**
     * Business methods that are exposed to web service clients must be annotated with javax.jws.WebMethod.
     * this method is called operation.
     * @param name
     * @return
     * 
     */
    @WebMethod
    public String sayHello(String name) {
        return message + name + ".";
    }
    
    @WebMethod
    @WebResult
    public List<Product> getListProduct(String category){
    	List<Product> list = new ArrayList<Product>();
    	Product pr1 = new Product("aa", "bb", 5.0);
    	Product pr2 = new Product("cc", "dd", 6.0);
    	list.add(pr1);
    	list.add(pr2);
    	if(category == "true"){
    		return list;
    	}
    	return null;
    }
}
